package com.jerry.controller;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.Calendar;
import java.util.Date;

/**
 * @Description
 * @author Jerry
 * @date 2016-09-09
 */
public class canlanderTest {

//    private Calendar customSetNextFireTime(Date sTime) {
////        DateTime sTimeJoda = new DateTime(sTime);
////        int sTimeMaxDay = sTimeJoda.dayOfMonth().getMaximumValue();//获取当前月的最大天数
////
////        int startTimeDay = sTimeJoda.getDayOfMonth(); //获取开始时间的天数
////
////        if(startTimeDay < sTimeMaxDay && startTimeDay != firstTimeDay && firstTimeDay <= sTimeMaxDay) {
////            sTimeJoda = sTimeJoda.withDayOfMonth(firstTimeDay);
////        }
////        return sTimeJoda.toGregorianCalendar();
//    }

    public static void main(String[] args) {
//        DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd");
//        //时间解析
//        DateTime dateTime1 = DateTime.parse("2016-10-31", format);
////        DateTime  dateTime1 = new DateTime("2016, 9, 30, 0, 0, 0, 0");
//        dateTime1.plusDays(20);
//
//        //时间格式化，输出==> 2012/12/21 23:22:45 Fri
//        String string_u = dateTime1.toString("E MM/dd/yyyy HH:mm:ss.SSS");
//        System.out.println(string_u);
//
//        DateTime dateTime = new DateTime("2016-9-30");
//        System.out.println(dateTime.plusDays(30).toString("E MM/dd/yyyy HH:mm:ss.SSS"));


        DateTime dateTime = new DateTime("2016-10-31");
        for (int i=1;i<10;i++){
            System.out.println(dateTime.plusMonths(i).toString("yyyy-MM-dd"));
        }

        DateTime sTimeJoda = new DateTime("2016-9-5");
        int sTimeMaxDay = sTimeJoda.dayOfMonth().getMaximumValue();//获取当前月的最大天数

        int startTimeDay = sTimeJoda.getDayOfMonth(); //获取开始时间的天数
        System.out.println(sTimeMaxDay);
        System.out.println(startTimeDay);
        System.out.println(sTimeJoda.toGregorianCalendar());

        int day = new LocalDate(new Date()).getDayOfMonth();
        System.out.println(day);

    }
}
